'use strict'

const fs = require('fs')
const path = require('path')
const router = require('koa-router')()
const basename = path.basename(module.filename)

fs.readdirSync(__dirname).filter(function(file) {
    return file !== basename &&
        file.indexOf('.') !== 0
}).forEach(function(file) {
    const mod = file.replace(/^(.*)\.js$/, '$1')
    router.use(`/v1/${mod}`, require(`./${mod}`).routes())
})

module.exports = router